package view.accciones;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;

import model.Proyecto;

import constants.PantallaConstants;
import controller.ManagerJerarquia;

public class EliminarEntidadDialogo extends JDialog{

	private JLabel eliminar;
	private JButton botonSi,botonNo;
	private boolean eliminarGlobal;
	
	public EliminarEntidadDialogo(){
		super(new JFrame(), "Eliminar Entidad", true);
		this.setResizable(false);
		this.setLocation(400, 200);
	
		this.initComponents();
	}

	private void initComponents() {
		eliminar = new JLabel("Desea eliminar la entidad en forma global?");
		botonSi = new JButton();
		botonNo = new JButton();
		this.eliminarGlobal = false;
		
		botonSi.setText(PantallaConstants.BOTON_SI);
		botonSi.addActionListener(new ActionListener() {
    	    public void actionPerformed(ActionEvent evt) {
    	    	botonSiActionPerformed(evt);
    	    }
    	});
		
		
		botonNo.setText(PantallaConstants.BOTON_NO);
		botonNo.addActionListener(new ActionListener() {
    	    public void actionPerformed(ActionEvent evt) {
    	    	botonNoActionPerformed(evt);
    	    }
    	});
		
		GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(botonSi)
                        .addGap(150,150,150)
                        .addComponent(botonNo))
                    .addGroup(layout.createSequentialGroup()
                    	.addComponent(eliminar)
                    	.addGap(20,20,20)))
                .addContainerGap(49, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
            	.addGap(10, 10, 10).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                      .addComponent(eliminar))	
                .addGap(25,25,25).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonSi)
                    .addComponent(botonNo))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        pack();
		
	}

	protected void botonNoActionPerformed(ActionEvent evt) {
		dispose();
	}

	protected void botonSiActionPerformed(ActionEvent evt) {
		this.eliminarGlobal = true;
		dispose();
	}

	public boolean isEliminarGlobal() {
		return eliminarGlobal;
	}
}
